package com.lanou3g.myapplication.adapter;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.lanou3g.myapplication.R;
import com.lanou3g.myapplication.bean.EventBusBean;

import java.util.ArrayList;

import de.greenrobot.event.EventBus;
import de.greenrobot.event.Subscribe;

/**
 * Created by dllo on 16/1/7.
 */
public class MainAdapter extends FragmentStatePagerAdapter implements View.OnClickListener {
    private ArrayList<Fragment> data;
    private Context context;
    String[] titles = {"推荐", "热点", "娱乐", "社会", "美女", "财经", "视频", "体育", "逗比", "军事", "闺房", "科技", "健康"};


    public MainAdapter(FragmentManager fm, ArrayList<Fragment> data, Context context) {
        super(fm);
        this.data = data;
        this.context = context;
    }

    @Override
    public Fragment getItem(int position) {
        return data.get(position);
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {

        return titles[position];
    }

    @Override
    public void onClick(View v) {
        Toast.makeText(context, "汽车", Toast.LENGTH_SHORT).show();
    }

//    public View getTabview(int position) {
//        View view = LayoutInflater.from(context).inflate(R.layout.viewpager_item, null);
//        TextView textView = (TextView) view.findViewById(R.id.viewpager_item_tv);
//        textView.setText(titles[position]);
//        return view;
//    }

//    @Override
//    public Object instantiateItem(ViewGroup container, int position) {
//        return super.instantiateItem(container, position);
//    }
}
